<%@ page import="com.qianfeng.pojo.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: jackiechan
  Date: 2021/8/31
  Time: 15:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--
要想显示数据,必须先获取到数据
--%>
<%--<%--%>
<%--    List<Student> studnets = (List<Student>) request.getAttribute("studnets");--%>
<%--%>--%>
<table border="1px">
    <tr>
       <th>id</th>
       <th>名字</th>
       <th>性别</th>
       <th>电话</th>
       <th>生日</th>
       <th>邮箱</th>
       <th>地址</th>
    </tr>
<%-- <%--%>
<%--     for (Student studnet : studnets) {--%>
<%--         out.print("<tr>");--%>
<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuId());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuName());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuGender());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuPhone());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getBornDate());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuEmail());--%>
<%--         out.print("</td>");--%>

<%--         out.print("<td>");--%>
<%--         out.print(studnet.getStuAddress());--%>
<%--         out.print("</td>");--%>

<%--         out.print("</tr>");--%>

<%--     }--%>

<%-- %>--%>

<%--

  <tr>
           <td>studnet.getStuId()</td>
        <td>studnet.getStuName()</td>
        <td>studnet.getStuGender()</td>
       <td>studnet.getStuPhone()</td>
       <td>studnet.getBornDate()</td>
       <td>studnet.getStuEmail()</td>
       <td>studnet.getStuAddress()</td>
       <tr>

--%>
    <c:forEach items="${studnets}" var="stu" varStatus="vs">
        <c:if test="${vs.index %2==0}">
            <tr style="color: red">
        </c:if>

        <c:if test="${vs.index %2==1}">
            <tr style="color: blue">
        </c:if>

        <td>${stu.stuId}</td>
        <td>${stu.stuName}</td>
        <td>${stu.stuGender}</td>
        <td>${stu.stuPhone}</td>
        <td>${stu.bornDate}</td>
        <td>${stu.stuEmail}</td>
        <td>${stu.stuAddress}</td>
        </tr>
    </c:forEach>
</table>

</body>
</html>
